import numpy as np
import matplotlib.pyplot as plt

def showChart(data):
    # 计算概率分布
    counts, bins = np.histogram(data, bins=256)
    probs = counts / sum(counts) * 100

    # 绘制概率分布图
    plt.bar(bins[:-1], probs, width=1, alpha=0.7)

    plt.ylim([0, 3])
    plt.yticks([0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0])

    plt.xlim([0, 255])
    plt.xticks([0, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250])

    # 添加标题和标签
    # plt.title('complex_PRNG')
    plt.xlabel('Value')
    plt.ylabel('Probability (%)')

    # 显示图像
    plt.show()


def showChart_2(data):
    # 计算概率分布
    counts, bins = np.histogram(data, bins=256)
    probs = counts / sum(counts) * 100

    plt.rcParams['font.sans-serif'] = ['SimSun']  # 设置中文字体为宋体
    plt.rcParams['font.serif'] = ['Times New Roman']  # 设置西文字体为Times New Roman

    # 解决负号'-'显示为方块的问题
    plt.rcParams['axes.unicode_minus'] = False

    # 绘制概率分布图
    plt.bar(bins[:-1], probs, width=0.004, alpha=0.7)

    plt.ylim([0, 5.0])
    plt.yticks([0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0])

    plt.xlim([0, 1])
    plt.xticks([0, 0.2, 0.4, 0.6, 0.8, 1.0])

    # 添加标题和标签
    # plt.title('complex_PRNG')
    plt.xlabel('Value')
    plt.ylabel('Probability (%)')

    # 显示图像
    plt.show()


def ss_chart(keylen,data):
    plt.scatter(range(keylen), data, s=5)
    plt.xlabel('Iteration')
    plt.ylabel('State Value')
    plt.ylim([0, 1.0])
    plt.xlim([0, 50000])
    # plt.title(f'Logistic Scatter Plot')
    plt.show()


